package cn.caplike.demo.repository.design.pattern.observer;


/**
 * @author: LiKe
 * @date: 2019-08-13 08:51
 */
public class App {

    public static void main(String[] args) {
        final Watched watched = new ConcreteWatched();//具体主题：类似按钮
        final Watcher tmpWatcher = new ConcreteWatcher("tmp");

        watched.addWatcher(new ConcreteWatcher(1));
        watched.addWatcher(tmpWatcher);
        watched.addWatcher(new ConcreteWatcher(3));

        watched.notifyWatchers("A-msg");//相当于触发按钮
        watched.removeWatcher(tmpWatcher);
        watched.notifyWatchers("B-msg");
    }
}
